/**
 */
package org.xtext.mydsl.scheduler.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.mydsl.scheduler.Actividad;
import org.xtext.mydsl.scheduler.ActividadA;
import org.xtext.mydsl.scheduler.Block;
import org.xtext.mydsl.scheduler.SchedulerPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Block</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.BlockImpl#getActividades <em>Actividades</em>}</li>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.BlockImpl#getBreak1 <em>Break1</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BlockImpl extends MinimalEObjectImpl.Container implements Block
{
  /**
   * The cached value of the '{@link #getActividades() <em>Actividades</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getActividades()
   * @generated
   * @ordered
   */
  protected EList<Actividad> actividades;

  /**
   * The cached value of the '{@link #getBreak1() <em>Break1</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBreak1()
   * @generated
   * @ordered
   */
  protected ActividadA break1;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected BlockImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SchedulerPackage.Literals.BLOCK;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Actividad> getActividades()
  {
    if (actividades == null)
    {
      actividades = new EObjectContainmentEList<Actividad>(Actividad.class, this, SchedulerPackage.BLOCK__ACTIVIDADES);
    }
    return actividades;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ActividadA getBreak1()
  {
    return break1;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetBreak1(ActividadA newBreak1, NotificationChain msgs)
  {
    ActividadA oldBreak1 = break1;
    break1 = newBreak1;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SchedulerPackage.BLOCK__BREAK1, oldBreak1, newBreak1);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBreak1(ActividadA newBreak1)
  {
    if (newBreak1 != break1)
    {
      NotificationChain msgs = null;
      if (break1 != null)
        msgs = ((InternalEObject)break1).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.BLOCK__BREAK1, null, msgs);
      if (newBreak1 != null)
        msgs = ((InternalEObject)newBreak1).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.BLOCK__BREAK1, null, msgs);
      msgs = basicSetBreak1(newBreak1, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SchedulerPackage.BLOCK__BREAK1, newBreak1, newBreak1));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SchedulerPackage.BLOCK__ACTIVIDADES:
        return ((InternalEList<?>)getActividades()).basicRemove(otherEnd, msgs);
      case SchedulerPackage.BLOCK__BREAK1:
        return basicSetBreak1(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SchedulerPackage.BLOCK__ACTIVIDADES:
        return getActividades();
      case SchedulerPackage.BLOCK__BREAK1:
        return getBreak1();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SchedulerPackage.BLOCK__ACTIVIDADES:
        getActividades().clear();
        getActividades().addAll((Collection<? extends Actividad>)newValue);
        return;
      case SchedulerPackage.BLOCK__BREAK1:
        setBreak1((ActividadA)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.BLOCK__ACTIVIDADES:
        getActividades().clear();
        return;
      case SchedulerPackage.BLOCK__BREAK1:
        setBreak1((ActividadA)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.BLOCK__ACTIVIDADES:
        return actividades != null && !actividades.isEmpty();
      case SchedulerPackage.BLOCK__BREAK1:
        return break1 != null;
    }
    return super.eIsSet(featureID);
  }

} //BlockImpl
